import Vue from 'vue';
import App from './App.vue';
import router from './router/index';
import axios from 'axios';
import iview from 'iview';
import 'iview/dist/styles/iview.css';
import store from './store/index';
import Cookies from 'js-cookie';

Vue.config.productionTip = false
Vue.prototype.$axios = axios;
Vue.use(iview)
axios.interceptors.request.use(
  config => {
  // 判断是否存在token，如果存在的话，则每个http header都加上token
    let token = sessionStorage.getItem('token')
    if (!config.headers.hasOwnProperty('token') && token) {
      config.headers.Authorization = token;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  });
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
